package com.ukao.pad.ui.splash;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.ukao.pad.R;
import com.ukao.pad.base.BaseActivity;
import com.ukao.pad.bean.SearchHistorysBean;
import com.ukao.pad.db.SearchHistoryDao;
import com.ukao.pad.ui.LoginActivity;
import com.ukao.pad.utils.CheckUtils;

import java.util.ArrayList;

import butterknife.ButterKnife;

public class SplashActivity extends BaseActivity {


    private SearchHistoryDao dao;
    private ArrayList<SearchHistorysBean> historywordsList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //不是正式环境不走欢迎页
        if(!CheckUtils.isOfficialServerUrl()){
            finish();
            Intent  mIntent=new Intent(this, LoginActivity.class);
            startActivity(mIntent);
            finish();
        }
        dao= new SearchHistoryDao(this);
        historywordsList= dao.findAll();
        if (historywordsList.size()>1){
            finish();
            Intent  mIntent=new Intent(this, LoginActivity.class);
            startActivity(mIntent);
        }
        setContentView(R.layout.activity_splash);
        ButterKnife.bind(this);
        initView();
    }

    @Override
    protected void initView() {
        //加载根碎片
        loadRootFragment(R.id.view_pager, SplashFragment.newInstance("",""));
    }

    @Override
    public void onBackPressedSupport() {
        if (getSupportFragmentManager().getBackStackEntryCount() > 1) {
            super.pop();
        }
    }


}
